package com.dcy.singleton.type8;

/**
 * @Author：dcy
 * @Description:
 * @Date: 2021/1/19 15:03
 */
public class SingletonTest08 {
    public static void main(String[] args) {
        System.out.println("枚举方式");
        Singleton instance = Singleton.INSTANCE;
        Singleton instance2 = Singleton.INSTANCE;

        System.out.println(instance == instance2);
        System.out.println(instance.hashCode());
        System.out.println(instance.hashCode());

        instance.sayOK();
    }
}

/**
 * 枚举方式
 */
enum Singleton{
    INSTANCE;

    public void sayOK(){
        System.out.println("ok~");
    }
}
